<?php
declare (strict_types = 1);
namespace app\topic\model;

use think\model\concern\SoftDelete;
use app\common\model\BaseModel;
use app\common\logic\Attach;

/**
 * 定义资讯数据模型
 */
class Topic extends BaseModel
{
    use softDelete;
    /**
     * 表名
     * @var string
     */
    protected $name = 'topic';

    protected $hidden = ['best_sort', 'mhm_id', 'fullcategorypath', 'delete_time'];

    /**
     * 定义字段类型
     * @var array
     */
    protected $type = [
        'id'            => 'integer',
        'title'         => 'string',
        'abstract'      => 'string',
        'content'       => 'string',
        'publish_time'  => 'integer',
        'update_time'   => 'integer',
        'delete_time'   => 'integer'
    ];

    /**
     * 定义表主键
     * @var string
     */
    protected $pk = 'id';


    public function coverUrl()
    {
        return $this->belongsTo(Attach::class, 'cover')->bind(['cover_url'=>'fileurl']);
    }
}
